package cn.kgc.novel.controller;

import cn.kgc.novel.service.BookcontextService;
import cn.kgc.novel.service.impl.BookcontextServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Job;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Slf4j
@Component
public class CruisePlanJob implements Job {
    @Resource
    private BookcontextService bookcontextService;

    public static CruisePlanJob cruisePlanJob;

    @PostConstruct
    public void init(){
        cruisePlanJob = this;
    }

    @Override
    public void execute(JobExecutionContext Context) throws JobExecutionException {
        try {
            JobDataMap jdMap = Context.getJobDetail().getJobDataMap();
            String cruiseId = (String) jdMap.get("cruiseId");
            Integer bid = (Integer) jdMap.get("bid");
            Integer uid = (Integer)jdMap.get("uid");
            Integer titleid = (Integer)jdMap.get("titleid");
            String panId = (String) jdMap.get("panId");
            String userId = (String) jdMap.get("userId");
            String appId = (String) jdMap.get("appId");
            //TODO 逻辑待补充
            BookcontextService bookcontextService = new BookcontextServiceImpl();
            System.out.println(bookcontextService==null);
            cruisePlanJob.bookcontextService.updatedraftchapter(bid,uid,titleid);
            log.info("这是一个动态时间调度任务....");
            log.info("cruisePlan-CruisePlanJob-计划执行开始===>panId:{}---cruiseId:{}---appId:{}---userId:{}---bid:{}---uid:{}---titleid:{}---resultBody:{}", panId, cruiseId,  appId,bid,uid,titleid,  userId, "he");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
